// Get Kerning Pairs public KerningTable GetKerningTable(string fontFilePath, int pointSize) { KerningTable kerningInfo = new KerningTable(); kerningInfo.kerningPairs = new List <KerningPair>(); // Temporary Array to hold the kerning paris from the Native Plugin. FT_KerningPair[] kerningPairs = new FT_KerningPair[1000]; int kpCount = TMPro_FontPlugin.FT_GetKerningPairs(fontFilePath, m_kerningSet, m_kerningSet.Length, kerningPairs); for (int i = 0; i < kpCount; i++) { // Proceed to add each kerning pairs. KerningPair kp = new KerningPair(kerningPairs[i].ascII_Left, kerningPairs[i].ascII_Right, kerningPairs[i].xAdvanceOffset * pointSize); kerningInfo.kerningPairs.Add(kp); } return(kerningInfo); }
public KerningTable GetKerningTable(string fontFilePath, int pointSize) { KerningTable kerningTable = new KerningTable(); kerningTable.kerningPairs = new List <KerningPair>(); FT_KerningPair[] array = new FT_KerningPair[7500]; int num = TMPro_FontPlugin.FT_GetKerningPairs(fontFilePath, m_kerningSet, m_kerningSet.Length, array); for (int i = 0; i < num; i++) { KerningPair kp = new KerningPair(array[i].ascII_Left, array[i].ascII_Right, array[i].xAdvanceOffset * (float)pointSize); int num2 = kerningTable.kerningPairs.FindIndex((KerningPair item) => item.AscII_Left == kp.AscII_Left && item.AscII_Right == kp.AscII_Right); if (num2 == -1) { kerningTable.kerningPairs.Add(kp); } else if (!TMP_Settings.warningsDisabled) { Debug.LogWarning("Kerning Key for [" + kp.AscII_Left + "] and [" + kp.AscII_Right + "] is a duplicate."); } } return(kerningTable); }
// Get Kerning Pairs public KerningTable GetKerningTable(string fontFilePath, int pointSize) { KerningTable kerningInfo = new KerningTable(); kerningInfo.kerningPairs = new List<KerningPair>(); // Temporary Array to hold the kerning pairs from the Native Plug-in. FT_KerningPair[] kerningPairs = new FT_KerningPair[1000]; int kpCount = TMPro_FontPlugin.FT_GetKerningPairs(fontFilePath, m_kerningSet, m_kerningSet.Length, kerningPairs); for (int i = 0; i < kpCount; i++) { // Proceed to add each kerning pairs. KerningPair kp = new KerningPair(kerningPairs[i].ascII_Left, kerningPairs[i].ascII_Right, kerningPairs[i].xAdvanceOffset * pointSize); kerningInfo.kerningPairs.Add(kp); } return kerningInfo; }
public static extern int FT_GetKerningPairs(string fontPath, int[] characterSet, int setCount, FT_KerningPair[] kerningPairs);
// Get Kerning Pairs public KerningTable GetKerningTable(string fontFilePath, int pointSize) { KerningTable kerningInfo = new KerningTable(); kerningInfo.kerningPairs = new List<KerningPair>(); // Temporary Array to hold the kerning pairs from the Native Plug-in. FT_KerningPair[] kerningPairs = new FT_KerningPair[5000]; int kpCount = TMPro_FontPlugin.FT_GetKerningPairs(fontFilePath, m_kerningSet, m_kerningSet.Length, kerningPairs); for (int i = 0; i < kpCount; i++) { // Proceed to add each kerning pairs. KerningPair kp = new KerningPair(kerningPairs[i].ascII_Left, kerningPairs[i].ascII_Right, kerningPairs[i].xAdvanceOffset * pointSize); // Filter kerning pairs to avoid duplicates int index = kerningInfo.kerningPairs.FindIndex(item => item.AscII_Left == kp.AscII_Left && item.AscII_Right == kp.AscII_Right); if (index == -1) kerningInfo.kerningPairs.Add(kp); else if (!TMP_Settings.warningsDisabled) Debug.LogWarning("Kerning Key for [" + kp.AscII_Left + "] and [" + kp.AscII_Right + "] is a duplicate."); } return kerningInfo; }