user-0 提问: 如何获得字库中的所有符号或文字

回复:
user: user-1
content: ......................................................

user: user-2
content: 学习一下了！

user: user-3
content: 仅供参考：#pragma comment(lib,"gdi32") #include <windows.h> #include <stdio.h>  int main() {     const DWORD uWidth = 18 + 17 * 256, uHeight = 18 + 17 * 128;      PBITMAPINFO pbmi = (PBITMAPINFO) LocalAlloc (LPTR, sizeof (BITMAPINFOHEADER) + sizeof (RGBQUAD) * 2);     pbmi->bmiHeader.biSize = sizeof (BITMAPINFOHEADER);     pbmi->bmiHeader.biWidth = uWidth;     pbmi->bmiHeader.biHeight = uHeight;     pbmi->bmiHeader.biPlanes = 1;     pbmi->bmiHeader.biBitCount = 1;     pbmi->bmiHeader.biSizeImage = ((uWidth + 31) & ~31) / 8 * uHeight;     pbmi->bmiColors[0].rgbBlue = 0;     pbmi->bmiColors[0].rgbGreen = 0;     pbmi->bmiColors[0].rgbRed = 0;     pbmi->bmiColors[1].rgbBlue = 255;     pbmi->bmiColors[1].rgbGreen = 255;     pbmi->bmiColors[1].rgbRed = 255;      HDC hDC = CreateCompatibleDC (0);     void * pvBits;     HBITMAP hBitmap = CreateDIBSection (hDC, pbmi, 0, &pvBits, NULL, 0);     SelectObject (hDC, hBitmap);     HFONT hFont = CreateFont (16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "宋体"); //  HFONT hFont = CreateFont (16, 0, 0, 0, 0, 0, 0, 0, SHIFTJIS_CHARSET, 0, 0, 0, 0, "宋体");     SelectObject (hDC, hFont);     BitBlt (hDC, 0, 0, uWidth, uHeight, NULL, 0, 0, WHITENESS);      char c[4];     int i, j;     for (i = 128; i < 256; i++) {         sprintf (c, "%02X", i);         TextOut (hDC, 1, (i - 127) * 17 + 1, c, 2);     }     for (j = 0; j < 256; j++) {         sprintf (c, "%02X", j);         TextOut (hDC, (j + 1)* 17 + 1, 1, c, 2);     }     for (i = 128; i < 256; i++) {         for (j = 0; j < 256; j++) {             c[0] = (char) i;             c[1] = (char) j;             TextOut (hDC, (j + 1) * 17 + 1, (i - 127) * 17 + 1, c, 2);         }     }     for (i = 0; i < 130; i++) {         MoveToEx (hDC, 0, i * 17, NULL);         LineTo (hDC, uWidth, i * 17);     }     for (j = 0; j < 258; j++) {         MoveToEx (hDC, j * 17, 0, NULL);         LineTo (hDC, j * 17, uHeight);     }      BITMAPFILEHEADER bmfh;     bmfh.bfType = *(PWORD) "BM";     bmfh.bfReserved1 = 0;     bmfh.bfReserved2 = 0;     bmfh.bfOffBits = sizeof (BITMAPFILEHEADER) + sizeof (BITMAPINFOHEADER) + sizeof (RGBQUAD) * 2;     bmfh.bfSize = bmfh.bfOffBits + pbmi->bmiHeader.biSizeImage;      HANDLE hFile = CreateFile ("goal.bmp", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);     if (hFile != INVALID_HANDLE_VALUE) {         DWORD dwWritten;         WriteFile (hFile, &bmfh, sizeof (BITMAPFILEHEADER), &dwWritten, NULL);         WriteFile (hFile, pbmi, sizeof (BITMAPINFOHEADER) + sizeof (RGBQUAD) * 2, &dwWritten, NULL);         WriteFile (hFile, pvBits, pbmi->bmiHeader.biSizeImage, &dwWritten, NULL);          CloseHandle (hFile);     }      DeleteObject (hFont);     DeleteObject (hBitmap);     DeleteDC (hDC);     LocalFree (pbmi);      return 0; }   趁CSDN的程序猿表情还没戒烟，我赶紧多抽两口！

user: user-4
content: 编码的意思就是你输入的字的内码，编码空间就是内码的取值范围。 结合你编程环境的实际情况，写个循环就好。

user: user-0
content: 引用 4 楼 forever74 的回复:最笨最简单的办法，循环穷举编码空间，找不到的跳过。编码空间怎么弄，能否详细说下吗

user: user-4
content: 最笨最简单的办法，循环穷举编码空间，找不到的跳过。

user: user-0
content: 我可以通过freetype输入自定义的文字，然后生成bmp图片，但是我不想输入自定义的字，想直接获得字体文件中的字，然后再将所有文字显示到一张图片中

user: user-0
content: 引用 1 楼 user-6 的回复:https://tchayen.github.io/posts/ttf-file-parsing看了下，都是JavaScript，看不太懂，而且我这边也只能用C

user: user-0
content: 引用 8 楼 早打大打打核战争 的回复:GetFontUnicodeRanges这个函数可以，我去找找用法。

user: user-0
content: 引用 6 楼 forever74 的回复:编码的意思就是你输入的字的内码，编码空间就是内码的取值范围。 结合你编程环境的实际情况，写个循环就好。好的，谢谢

user: user-3
content: WCRANGE [This is preliminary documentation and subject to change.]   The WCRANGE structure specifies a range of Unicode characters.  typedef struct tagWCRANGE {     WCHAR  wcLow;     USHORT cGlyphs; } WCRANGE, *PWCRANGE,FAR *LPWCRANGE;   Members wcLow  Low Unicode code point in the range of supported Unicode code points.  cGlyphs  Number of supported Unicode code points in this range.  QuickInfo   Windows NT: Requires version 5.0 or later.   Windows: Requires Windows 98 or later.   Windows CE: Unsupported.   Header: Declared in wingdi.h.  See Also Fonts and Text Overview, Font and Text Structures, GLYPHSET

user: user-3
content: GetFontUnicodeRanges [This is preliminary documentation and subject to change.]   The GetFontUnicodeRanges function returns information about which Unicode characters are supported by a font. The information is returned as a GLYPHSET structure.  WINGDIAPI DWORD WINAPI GetFontUnicodeRanges(   HDC hdc,         // handle to the device context   LPGLYPHSET lpgs  // pointer to the glyph set structure );   Parameters hdc  Handle to the device context.  lpgs  Pointer to a buffer to contain the GLYPHSET structure. If this parameter is NULL, the function returns a pointer to the GLYPHSET structure for the current font.  Return Values If the function succeeds, it returns a pointer to the font's GLYPHSET structure for the current device context.   If the function fails, it returns zero.  QuickInfo   Windows NT: Requires version 5.0 or later.   Windows: Unsupported.   Windows CE: Unsupported.   Header: Declared in wingdi.h.   Import Library: Use gdi32.lib.  See Also Fonts and Text Overview, Font and Text Functions, GLYPHSET    GLYPHSET [This is preliminary documentation and subject to change.]   The GLYPHSET structure contains information about a range of Unicode code points.  typedef struct tagGLYPHSET {     DWORD    cbThis;     DWORD    flAccel;     DWORD    cGlyphsSupported;     DWORD    cRanges;     WCRANGE  ranges[1]; } GLYPHSET, *PGLYPHSET, FAR *LPGLYPHSET;   Members cbThis  Size, in bytes, of this structure.  flAccel  Flags describing the maximum size of the glyph indices. This member can be the following value: Value Meaning  GS_8BIT_INDICES Treat glyph indices as 8-bit wide values. Otherwise, they are 16-bit wide values.    cGlyphsSupported  Total number of Unicode code points supported in the font.  cRanges  Total number of Unicode ranges in ranges.  ranges  Array of Unicode ranges that are supported in the font.  QuickInfo   Windows NT: Requires version 5.0 or later.   Windows: Requires Windows 98 or later.   Windows CE: Unsupported.   Header: Declared in wingdi.h.  See Also Fonts and Text Overview, Font and Text Structures, GetFontUnicodeRanges, WCRANGE

user: user-5
content: GetFontUnicodeRanges

user: user-6
content: https://tchayen.github.io/posts/ttf-file-parsing