How to read .ggxml files

isnorden

Amnesiac Modder
Joined
Jul 6, 2012
Messages
608
Location
Madison, Wisconsin, USA
I've created a set of font icons for a mod project lately, but was frustrated to learn that making the icons "work" requires editing a .ggxml file. None of my existing software opens or reads that file type; which program(s) do I need to do that? (And on a related note, what's the difference between GGXML and regular XML?) :confused:


Moderator Action: Thread moved to the Tutorial section for reference (see post #3 and #7)
 
Any plain text editor will open and edit them - Notepad, Notepad++, vi, whatever

They are XML files, but with a different extension.

They MUST have the same base name as the DDS file they relate to (so for CivSymbolsColor45_DLC_D.dds it MUST be CivSymbolsColor45_DLC_D.ggxml) and I'm pretty sure case is significant.

The width and height attributes in the <texture> element must match the dimensions of the DDS file

The <styles>, <import> and <tools> elements can all be "minimal" (not sure if you can completely omit them, but you can certainly remove just about everything from them)

The following is the ggxml file for my Pin Fonts (four 22x22 icons per row, two rows)

Code:
<?xml version="1.0" encoding="UTF-8" ?>
<glyphgen>
  <textures width="88" height="44">
    <texture name="" src="PinFont.dds" allowcolor="1" alloweffects="1" inuse="1" />
  </textures>

  <styles count="1"><style name=""><layers count="1"><layer tex="" /></layers></style></styles>
  
  <glyphs count="8" fudgeadv="0" ascadj="-6" spacing="0" height="0" ascent="0" descent="0">
    <glyph ch="1" u="0" v="0" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="2" u="22" v="0" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="3" u="44" v="0" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="4" u="66" v="0" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="5" u="0" v="22" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="6" u="22" v="22" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="7" u="44" v="22" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="8" u="66" v="22" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
  </glyphs>

  <imports count="0"/>
  <toolonly>
    <metainfo pt="0.000000" width="256" height="256" alphabias="64" maxsize="256" bestfit="0" pow2="1" freetype="2" fontsrc="" />
    <glyphsets><set name="GlyphSetAscii" /></glyphsets>
  </toolonly>
</glyphgen>

HTH

W
 
They open fine in the SDK, but IIRC you can't use that, so I'm not sure. Have you tried Notepad?

My computer doesn't "know" that .ggxml is openable with a text editor, apparently--I'll have to give Notepad++ a shot. And yes, I've tried the SDK, although that crashes on my old PC more often than it works. Thank you for the tip all the same!
 
Any plain text editor will open and edit them - Notepad, Notepad++, vi, whatever

They are XML files, but with a different extension.

They MUST have the same base name as the DDS file they relate to (so for CivSymbolsColor45_DLC_D.dds it MUST be CivSymbolsColor45_DLC_D.ggxml) and I'm pretty sure case is significant.

The width and height attributes in the <texture> element must match the dimensions of the DDS file

The <styles>, <import> and <tools> elements can all be "minimal" (not sure if you can completely omit them, but you can certainly remove just about everything from them)

The following is the ggxml file for my Pin Fonts (four 22x22 icons per row, two rows)

Code:
<?xml version="1.0" encoding="UTF-8" ?>
<glyphgen>
  <textures width="88" height="44">
    <texture name="" src="PinFont.dds" allowcolor="1" alloweffects="1" inuse="1" />
  </textures>

  <styles count="1"><style name=""><layers count="1"><layer tex="" /></layers></style></styles>
  
  <glyphs count="8" fudgeadv="0" ascadj="-6" spacing="0" height="0" ascent="0" descent="0">
    <glyph ch="1" u="0" v="0" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="2" u="22" v="0" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="3" u="44" v="0" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="4" u="66" v="0" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="5" u="0" v="22" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="6" u="22" v="22" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="7" u="44" v="22" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="8" u="66" v="22" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
  </glyphs>

  <imports count="0"/>
  <toolonly>
    <metainfo pt="0.000000" width="256" height="256" alphabias="64" maxsize="256" bestfit="0" pow2="1" freetype="2" fontsrc="" />
    <glyphsets><set name="GlyphSetAscii" /></glyphsets>
  </toolonly>
</glyphgen>

HTH

W

Thanks for the code snippet; I've got nine font icons total, so being able to include them all in one file is a plus. Since I've never worked with font icons or GGXML before, I still have a few "clueless newbie" questions:

  1. What do the values "u", "v", and "ch" represent?
  2. How would I change the code above to handle three rows of three?
  3. Would the block of code between the two <toolonly> tabs be standard for any typical font atlas?
 
Thanks for the code snippet; I've got nine font icons total, so being able to include them all in one file is a plus. Since I've never worked with font icons or GGXML before, I still have a few "clueless newbie" questions:

There is only one published "bible" mod (by S Seckman) on the Workshop to follow, and that is vague at best, so we're all pretty much using guesswork here!

What do the values "u", "v", and "ch" represent?

ch is the "character number" (see below)
u and v represent the pixel offset of the font in the DDS file (which is why u increments by 22 - the width of the font icon - for the next character, until you get to the end of the row, then it resets to 0 and v is increment by 22 - the height of the font icon - for characters in the next row

The usage of a, b and c is unknown (and unanswered :( by Firaxis)
The "best guess" is that a and c are always 0 and b is width
originx = 0 and originy=height places the origin in the bottom left corner, you can play with those values if you need negative leading (eg for ligatures) or descenders, but for font icons you can leave them be


Would the block of code between the two <toolonly> tabs be standard for any typical font atlas?

Yes (as is the <imports> section)

How would I change the code above to handle three rows of three?

Code:
<?xml version="1.0" encoding="UTF-8" ?>
<glyphgen>
  <textures width="[B][COLOR="Red"]66[/COLOR][/B]" height="[B][COLOR="Red"]66[/COLOR][/B]">
    <texture name="" src="[B][COLOR="Magenta"]NordicGlyphs[/COLOR][/B].dds" allowcolor="1" alloweffects="1" inuse="1" />
  </textures>

  <styles count="1"><style name=""><layers count="1"><layer tex="" /></layers></style></styles>
  
  <glyphs count="[COLOR="red"][B]9[/B][/COLOR]" fudgeadv="0" ascadj="-6" spacing="0" height="0" ascent="0" descent="0">
    <glyph ch="[B][COLOR="Orange"]1[/COLOR][/B]" u="0" v="0" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="[B][COLOR="seagreen"]2[/COLOR][/B]" u="22" v="0" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="3" u="44" v="0" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="4" u="[B][COLOR="red"]0[/COLOR][/B]" v="[COLOR="red"][B]22[/B][/COLOR]" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="5" u="[COLOR="red"][B]22[/B][/COLOR]" v="22" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="6" u="[B][COLOR="red"]44[/COLOR][/B]" v="22" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="7" u="[COLOR="red"][B]0[/B][/COLOR]" v="[COLOR="red"][B]44[/B][/COLOR]" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    <glyph ch="8" u="[B][COLOR="red"]22[/COLOR][/B]" v="[B][COLOR="red"]44[/COLOR][/B]" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />
    [COLOR="red"][B]<glyph ch="9" u="44" v="44" width="22" height="22" a="0" b="22" c="0" originx="0" originy="22" />[/B][/COLOR]
  </glyphs>

  <imports count="0"/>
  <toolonly>
    <metainfo pt="0.000000" width="256" height="256" alphabias="64" maxsize="256" bestfit="0" pow2="1" freetype="2" fontsrc="" />
    <glyphsets><set name="GlyphSetAscii" /></glyphsets>
  </toolonly>
</glyphgen>

You will also need a corresponding xml file to map [ICON_XYZ] type stings to your glyphs

Code:
<?xml version="1.0" encoding="utf-8"?>
<GameData>
  <IconFontTextures>
    <Row>
      <IconFontTexture>ICON_NORDIC_FONT</IconFontTexture>
      <IconFontTextureFile>[B][COLOR="Magenta"]NordicGlyphs[/COLOR][/B]</IconFontTextureFile>
    </Row>
  </IconFontTextures>

  <IconFontMapping>
    <Row>
      <IconName>ICON_NORDIC_1</IconName>
      <IconFontTexture>ICON_NORDIC_FONT</IconFontTexture>
      <IconMapping>[B][COLOR="orange"]1[/COLOR][/B]</IconMapping>
    </Row>
    <Row>
      <IconName>ICON_NORDIC_2</IconName>
      <IconFontTexture>ICON_NORDIC_FONT</IconFontTexture>
      <IconMapping>[B][COLOR="SeaGreen"]2[/COLOR][/B]</IconMapping>
    </Row>

    ....
  </IconFontMapping>
</GameData>

The IconMapping number corresponds to the ch number

You would then use "Hello [ICON_NORDIC_1] World [ICON_NORDIC_2]" to use them. If "nordic 1" was a plus sign (+) and "nordic 2" a minus sign (-) that would display as "Hello + World -"

Note that the IconNames MUST start with "ICON_" or the string parsers won't substitue them, so if you tried to use "MY_ICON_NORDIC_1" as the icon name you wouldn't get any icons in you strings, just the text "[MY_ICON_NORDIC_1]"

In this example you would end up with three files - NordicGlyphs.dds, NordicGlyphs.ggxml and NordicFont.xml - the first two are VFS=true, the last needs an OnModActivated -> UpdateDatabase entry

HTH

W
 
Any plain text editor will open and edit them - Notepad, Notepad++, vi, whatever
Of course but, as we all know, VI was written by a bunch of communists and it was Bin Laden's favorite application. Also if you take its Unicode-16 representation with Little Endian convention and converts it to the 23 basis, it gives you 666.



Sorry, I could not refrain myself.
 
Back
Top Bottom