Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (91,322 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

Sign in to follow this  
Finney

Having a issue with changing/adding/embedding fonts...

Recommended Posts

Finney

Hey guys, so I was toying around with GTA IV again today, and I'm trying to get the fonts swap'd out.

 

I'm just failing to find the syntax I need once more...

 

I've got the desired font into the project, its embedded, and binary as you'd expect it needing to be... however, I'm unable to figure out how to access it and replace it.

 

I'm away that I may need to differ the two between using System.Drawing, and GTA.Drawing (I'm not sure what its called off hand... I'm just working from memory.).

 

Is there a simple way to grab and set it, such as the same as setting a texture? Resources.GetTeuxtre("stringoffile.png"); for example? I've seem what feels like some over complicated methods for adding phone to windows apps as embedded using different types of DLLs... but I'd prefer to keep it light weight.

 

Anyone got any advice on replacing the damn near unreadable .Pixel/.Screen font that GTA IV has?

Share this post


Link to post
Share on other sites
Jitnaught

This is how you would do it with a file.

System.Drawing.Text.PrivateFontCollection privateFonts = new PrivateFontCollection(); //using System.Drawing.Text;privateFonts.AddFontFile(@"C:\mycustomfont.ttf"); //font locationGTA.Font font = new GTA.Font(privateFonts.Families[0].Name, 12/*height*/, FontScaling.Pixel);

And here is, possibly, how you would do it with a resource.

byte[] fontData = Resources.GetData("BankGothic Bold.ttf");IntPtr fontPtr = Marshal.AllocCoTaskMem(fontData.Length); //using System.Runtime.InteropServices; Marshal.Copy(fontData, 0, fontPtr, fontData.Length);_fonts.AddMemoryFont(fontPtr, fontData.Length);Marshal.FreeCoTaskMem(fontPtr);GTA.Font customFont = new GTA.Font(_fonts.Families[0].Name, 6.0f, FontScaling.Pixel);

No clue if it works though, I just copy/pasted it from online and edited it a bit.

Edited by LetsPlayOrDy

Share this post


Link to post
Share on other sites
Finney

Ok - the method you gave me works pretty well. I'm still not liking the damn .Pixel scale down can make even pretty clear text, unclear at smaller scales... :|

 

I haven't tried the one thats within the resources yet - I'll most likely give that a go in a bit. Thanks for the prompt reply. I see that with the resources one, Unsafe is used - makes me uncomfortable. Don't really even know what that is, I mean toggling it wasn't a problem but I really don't like to dive into things that are called "Unsafe"

 

I'll let you know my results thanks again. I put this one in the right section! :D

Share this post


Link to post
Share on other sites
Jitnaught

The unsafe keyword denotes an unsafe context, which is required for any operation involving pointers.

Edited by LetsPlayOrDy

Share this post


Link to post
Share on other sites
Finney

Yea so using regular system fonts, and changing the fonts around are pretty straight forward. I had some issues grabbed a .ttf as a embedded resources - regardless, the next glaring issue I'm facing is using a font size thats "small" will leave it pixelated depending on how small you go... you know of any work arounds for this?

Share this post


Link to post
Share on other sites
Jitnaught

Yea so using regular system fonts, and changing the fonts around are pretty straight forward. I had some issues grabbed a .ttf as a embedded resources - regardless, the next glaring issue I'm facing is using a font size thats "small" will leave it pixelated depending on how small you go... you know of any work arounds for this?

No I don't. I really don't have any experience with this kind of stuff. All of that code is from Google and I just converted it for GTA use lol.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.