跳到主内容

自定义字体生成器

给你的服务器一套自己的字体。拖入一个 .ttf 或 .otf,页面就会在你的浏览器里直接生成 GTA V 需要的 Scaleform .gfx 文件,不用安装任何转换工具。你可以在玩家实际使用的分辨率下,看到文字画在真实的洛圣都画面上,带着文本 native 提供的缩放、颜色、换行、阴影和描边。然后下载一个资源:字体放在 stream 里,附带注册用的 Lua 和配套的绘制代码。

这个工具和它的说明目前是英文的。

配置与代码字体, GFX, DrawText, 下载查看文档

How to use it

  1. Drop a .ttf or .otf on the page. It is read on your own machine.
  2. Pick the characters to include. Basic Latin is the smallest file and covers most HUDs.
  3. Set the file name and the font name. They are two different things: the first is the name of the .gfx on disk, the second is the name of the font inside it.
  4. Type your text and set the scale, colour, position, wrapping, shadow and outline.
  5. Download the resource, drop it in your resources folder and add ensure for it.

What a custom font needs in game

GTA V draws text through Scaleform, so a font has to be a Scaleform GFx font library, a.gfx file. Four things have to line up:

  • The .gfx has to be in the resource's stream folder. That is what hands it to the game's streamer, and RegisterFontFile only works on a file the streamer already knows about.
  • RegisterFontFile('name') takes the file name without the extension. It queues the library; the client loads it over the next frames.
  • RegisterFontId('FontName') takes the name of the font inside that library and gives you back an index.
  • SetTextFont(id) with that index, before you begin the text command.

A font needs no files entry and no data_file line in the manifest.files makes something fetchable by the client, which is not the same as streaming it, and data_file is for the game's own meta files. The generated manifest says this in a comment so nobody adds one later.

The traps

What you seeWhy
The stock font on the first frames, then yoursThe library is still streaming in. RegisterFontFile queues it and no native reports when it is ready, so wait a moment after registering before you draw. The generated client.lua does.
The wrong font, or the stock one, foreverA hardcoded font id. RegisterFontId returns an index into a list built while the client runs, so it shifts if another resource registers a font before yours. Keep the value you were handed.
Empty boxes where some letters should beThose characters are not in the file. Accents, Cyrillic, Greek and the lira sign only ship if you picked a character set that includes them. The preview shows the same boxes.
Your colour, scale or shadow is ignoredThe call came after BeginTextCommandDisplayText. EverySetText... call has to come first.
Centring does nothingSetTextJustification needs a box to justify inside, so it only does something together with SetTextWrap.
Long text is cut offOne text component carries 99 characters. Split it and add it in pieces.
Nothing happens at allRegisterFontID with a capital D is not a native. It isRegisterFontId.

What the preview can and cannot show

The text on the screenshot is drawn from the glyph outlines read back out of the .gfx this page just built, not from your browser's own rendering of the uploaded font. The letter shapes, the spacing between them, the line breaks and anything missing are therefore exactly what the file holds.

The size is close rather than exact. GTA works the final text height out from the font's own ascent, so there is no clean formula that holds for every font; if you need the real number, read it in game with GetTextScaleHeight. The drop shadow and outline are drawn the way the game draws them but are not pixel for pixel, and no browser can tell you how your font looks after the game's own antialiasing.

Privacy and licensing

Nothing is uploaded. The page reads the font, builds the .gfx and packs the zip in your browser, and this tool has no server side. Fonts are licensed work, so check that the one you are shipping allows embedding before you put it on a server.