All Projects → nullboundary → glfont

nullboundary / glfont

Licence: other
A modern opengl text rending library for Golang

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to glfont

vue-resize-text
A vue directive which automatically resize font size based on element width.
Stars: ✭ 65 (+140.74%)
Mutual labels:  font, text
Wgpu glyph
A fast text renderer for wgpu (https://github.com/gfx-rs/wgpu)
Stars: ✭ 159 (+488.89%)
Mutual labels:  font, text
pygame-text-input
a small module that enables you to input text with your keyboard using pygame
Stars: ✭ 114 (+322.22%)
Mutual labels:  font, text
Typogenic
Signed-distance field text rendering for Unity
Stars: ✭ 183 (+577.78%)
Mutual labels:  font, text
Zfont
💬 Text plugin for Zdog - works with any .ttf font!
Stars: ✭ 126 (+366.67%)
Mutual labels:  font, text
baseline
New method for creating leading on the web
Stars: ✭ 31 (+14.81%)
Mutual labels:  font, text
github-code-font-changer
🎨 Change and customize the boring GitHub code viewer font.
Stars: ✭ 52 (+92.59%)
Mutual labels:  font
ss-search
The most basic, yet powerful text search.
Stars: ✭ 41 (+51.85%)
Mutual labels:  text
sinonimo
🇧🇷 Sinonimo é um pacote Node que traz sinônimos de palavras em português
Stars: ✭ 14 (-48.15%)
Mutual labels:  text
FanWunMing
A Simplified-Chinese-to-Traditional-Chinese font based on GenYoMin, which can handle the one-to-many problem | 繁媛明朝是基於源樣明體開發的簡轉繁字型,能處理一簡對多繁
Stars: ✭ 128 (+374.07%)
Mutual labels:  font
craft-text-detector
Packaged, Pytorch-based, easy to use, cross-platform version of the CRAFT text detector
Stars: ✭ 151 (+459.26%)
Mutual labels:  text
FMX.FontAwesome
[FireMonkey] FontAwesome
Stars: ✭ 21 (-22.22%)
Mutual labels:  font
hzk-pixel-font
中文像素字体,12 和 16 像素。
Stars: ✭ 14 (-48.15%)
Mutual labels:  font
texthighlighter
a no dependency typescript npm package for highlighting user selected text
Stars: ✭ 17 (-37.04%)
Mutual labels:  text
ifont
🦀 iFont - serverless-based cloud font library
Stars: ✭ 32 (+18.52%)
Mutual labels:  font
emojione-color
OpenType-SVG font of EmojiOne 2.3
Stars: ✭ 112 (+314.81%)
Mutual labels:  font
iwata-asks-downloader
Tool to download Iwata Asks interviews (none of which are stored in this repo)
Stars: ✭ 17 (-37.04%)
Mutual labels:  text
ImageCropper
✂️ Detect and crop faces, barcodes, texts or rectangle in image with iOS 11 Vision (iOS 10 Core Image) api.(图片裁剪:支持人脸、二维码/条形码、文本、方框)
Stars: ✭ 17 (-37.04%)
Mutual labels:  text
markdown-utils
Convert plain text into snippets of markdown.
Stars: ✭ 28 (+3.7%)
Mutual labels:  text
split
A string split function and iterator for Lua
Stars: ✭ 15 (-44.44%)
Mutual labels:  text

Go Report Card

Name    : glfont Library                      
Author  : Noah Shibley, http://socialhardware.net                       
Date    : June 16th 2016                                 
Notes   : A modern opengl text rendering library for golang
Dependencies:   freetype, go-gl, glfw

Function List:

func LoadFont

func LoadFont(file string, scale int32, windowWidth int, windowHeight int) (*Font, error)

LoadFont loads the specified font at the given scale. The default character set is ASCII (codepoints 32 to 127).

func LoadTrueTypeFont

func LoadTrueTypeFont(program uint32, r io.Reader, scale int32, low, high rune, dir Direction) (*Font, error)

LoadTrueTypeFont builds buffers and textures based on a ttf files gylphs.

func (*Font) GenerateGlyphs

func (f *Font) GenerateGlyphs(low, high rune) error

GenerateGlyphs builds additional glyphs for non-ASCII Unicode codepoints.

func (*Font) Printf

func (f *Font) Printf(x, y float32, scale float32, fs string, argv ...interface{}) error

Printf draws a string to the screen, takes a list of arguments like printf

func (*Font) SetColor

func (f *Font) SetColor(red float32, green float32, blue float32, alpha float32)

SetColor allows you to set the text color to be used when you draw the text

func (f *Font) UpdateResolution

func (f *Font) UpdateResolution(windowWidth int, windowHeight int)

UpdateResolution is needed when the viewport is resized

func (f *Font) Width

func (f *Font) Width(scale float32, fs string, argv ...interface{}) float32

Width returns the width of a piece of text in pixels


Example:

package main

import (
	"fmt"
	"log"
	"runtime"

	"github.com/go-gl/gl/all-core/gl"
	"github.com/go-gl/glfw/v3.1/glfw"
	"github.com/nullboundary/glfont"
)

const windowWidth = 1920
const windowHeight = 1080

func init() {
	runtime.LockOSThread()
}

func main() {

	if err := glfw.Init(); err != nil {
		log.Fatalln("failed to initialize glfw:", err)
	}
	defer glfw.Terminate()

	glfw.WindowHint(glfw.Resizable, glfw.True)
	glfw.WindowHint(glfw.ContextVersionMajor, 3)
	glfw.WindowHint(glfw.ContextVersionMinor, 2)
	glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
	glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)

	window, _ := glfw.CreateWindow(int(windowWidth), int(windowHeight), "glfontExample", glfw.GetPrimaryMonitor(), nil)

	window.MakeContextCurrent()
	glfw.SwapInterval(1)
	
	if err := gl.Init(); err != nil { 
		panic(err)
	}

	//load font (fontfile, font scale, window width, window height
	font, err := glfont.LoadFont("Roboto-Light.ttf", int32(52), windowWidth, windowHeight)
	if err != nil {
		log.Panicf("LoadFont: %v", err)
	}

	gl.Enable(gl.DEPTH_TEST)
	gl.DepthFunc(gl.LESS)
	gl.ClearColor(0.0, 0.0, 0.0, 0.0)

	for !window.ShouldClose() {
		gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

     //set color and draw text
		font.SetColor(1.0, 1.0, 1.0, 1.0) //r,g,b,a font color
		font.Printf(100, 100, 1.0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.") //x,y,scale,string,printf args

		window.SwapBuffers()
		glfw.PollEvents()

	}
}

Contributors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].