{"id":19757024,"url":"https://github.com/jtberglund/glfont","last_synced_at":"2025-04-30T12:31:08.273Z","repository":{"id":35470540,"uuid":"39738847","full_name":"jtberglund/GLFont","owner":"jtberglund","description":"Text-rendering library written in C++ for OpenGL 3.3, using FreeType 2.","archived":false,"fork":false,"pushed_at":"2023-09-18T19:46:47.000Z","size":46,"stargazers_count":47,"open_issues_count":3,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-17T03:07:09.996Z","etag":null,"topics":["cpp","font","freetype","opengl"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":"Unmaintained","scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jtberglund.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-26T19:29:57.000Z","updated_at":"2024-02-13T07:24:24.000Z","dependencies_parsed_at":"2022-09-17T19:11:44.810Z","dependency_job_id":null,"html_url":"https://github.com/jtberglund/GLFont","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtberglund%2FGLFont","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtberglund%2FGLFont/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtberglund%2FGLFont/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtberglund%2FGLFont/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jtberglund","download_url":"https://codeload.github.com/jtberglund/GLFont/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224208028,"owners_count":17273699,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","font","freetype","opengl"],"created_at":"2024-11-12T03:17:52.017Z","updated_at":"2024-11-12T03:17:52.746Z","avatar_url":"https://github.com/jtberglund.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GLFont\nGLFont is a text-rendering library written in C++ for OpenGL 3.3, using FreeType 2.\n\n## Dependencies\n1. Freetype - http://freetype.org/\n2. GLM - http://glm.g-truc.net/0.9.4/index.html\n3. GLEW - http://glew.sourceforge.net/build.html\n4. GLFW - http://www.glfw.org/ (This is only necessary for the included test project. You can still use GLFont with your own application without GLFW)\n\n## C++ Quick Start\n\n### Initialize library and create label\nFirst create a font face to use for our labels.\n```c++\nshared_ptr\u003cGLFont\u003e glFont = shared_ptr\u003cGLFont\u003e(new GLFont(\".../myFont.ttf\"));\n```\n\nNow create a label, passing in the font face we just created.\n\n```c++\n// Some values we will use to create our labels\nint startX = 100;\nint startY = 100;\nint windowWidth = 800;\nint windowHeight = 600;\n\nunique_ptr\u003cFTLabel\u003e label = unique_ptr\u003cFTLabel\u003e(new FTLabel(\n  glfont,         // Font face handle\n  \"Hello world!\", // Text to render\n  startX,\n  startY,\n  windowWidth,\n  windowHeight\n));\n```\nNote that the starting x and y coords should be in window space.\nThis means (0,0) is at the top-left corner.\n\nAdditionally, we could specify a max width and/or height for our text. For example, the following will print a paragraph starting at window coordinates (100, 100), with a bounding box of 200 x 100.\n```c++\nint maxWidth = 200;\nint maxHeight = 100;\nunique_ptr\u003cFTLabel\u003e label = unique_ptr\u003cFTLabel\u003e(new FTLabel(\n  glFont,\n  \"[long paragraph here]\",\n  startX,\n  startY,\n  maxWidth,\n  maxWidth,\n  windowWidth,\n  windowHeight\n));\n```  \n\nYou can manually change the size or starting position of your label at any time. This is often done when the window is resized (unless you are using absolute label positions that do not change depending on window size).\n\nThis will set our label to start being drawn at (500, 250):\n```c++\nlabel-\u003esetPosition(500, 250);\n```\n\nSet max width to 100 and max height to 100:\n```c++\nlabel-\u003esetSize(100, 100);\n```\n\n### Font Settings\n\nSet the alignment, color, or size of the label text.\n```c++\nlabel-\u003esetPixelSize(24);\nlabel-\u003esetIndentation(50);\nlabel-\u003esetAlignment(FTLabel::FontFlags::LeftAligned);\nlabel-\u003esetColor(0.89, 0.26, 0.3, 0.9);\n```\n\nRotate text 90 degrees on the y axis:\n\n```c++\nlabel-\u003erotate(90, 0, 1, 0);\n```\n\nAdditionally, set font options with FTLabel::setFontFlags()\n```c++\nlabel-\u003esetFontFlags(FontFlags::WordWrap | FontFlags::Indented);\n```\n\n### Rendering Text\nIn the render loop, simply call FTLabel::render()\n```c++\nlabel-\u003erender();\n```\n\n### Additional Notes\nWhenever the window is resized, you should update the window size of your label\n```c++\nlabel-\u003esetWindowSize(windowWidth, windowSize);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtberglund%2Fglfont","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjtberglund%2Fglfont","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtberglund%2Fglfont/lists"}