Coder Social home page Coder Social logo

go-findfont's Introduction

PkgGoDev Go Report Card License MIT

go-findfont

A platform-agnostic go (golang) library to easily locate truetype font files in your system's user and system font directories.

What?

go-findfont is a golang library that allows you to locate font file on your system. The library is currently aware of the default font directories on Linux/Unix, Windows, and MacOS.

How?

Installation

Installing go-findfont is as easy as

go get -u github.com/flopp/go-findfont

Library Usage

import (
  "fmt"
  "io/ioutil"
  
  "github.com/flopp/go-findfont"
  "github.com/golang/freetype/truetype"
)

func main() {
  fontPath, err := findfont.Find("arial.ttf")
  if err != nil {
    panic(err)
  }
  fmt.Printf("Found 'arial.ttf' in '%s'\n", fontPath)

  // load the font with the freetype library
  fontData, err := ioutil.ReadFile(fontPath)
  if err != nil {
    panic(err)
  }
  font, err := truetype.Parse(fontData)
  if err != nil {
    panic(err)
  }

  // use the font...
}

License

Copyright 2016 Florian Pigorsch. All rights reserved.

Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

go-findfont's People

Contributors

bcvery1 avatar beta avatar flopp avatar joshvarga avatar korya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-findfont's Issues

I think I can get the font name supported by the system?

  • fc-list :lang=zh
/System/Library/Fonts/Hiragino Sans GB.ttc: Hiragino Sans GB,冬青黑體簡體中文,ヒラギノ角ゴ 簡体中文,冬青黑体简体中文,Hiragino Sans GB W6,冬青黑體簡體中文 W6,ヒラギノ角ゴ 簡体中文 W6,冬青黑体简体中文 W6:style=W6,Bold
/System/Library/Fonts/PingFang.ttc: PingFang TC,蘋方\-繁,苹方\-繁:style=Semibold,中粗體,中粗体
/System/Library/AssetsV2/com_apple_MobileAsset_Font7/3fcd72bc350b229eea0f818e5deecfc49585c02c.asset/AssetData/AppleLiSung-Light.ttf: Apple LiSung:style=Light,Fin,Mager,Chiaro,Licht,Fina,Ohut
/System/Library/AssetsV2/com_apple_MobileAsset_Font7/e2d3f9277678ccbf64020abef4c0eb9a1de1bed3.asset/AssetData/Lantinghei.ttc: Lantinghei TC,蘭亭黑\-繁,兰亭黑\-繁:style=Extralight,纖黑,纤黑

Feature request - add .otf

Since the golang.org/x/image/font/sfnt package reads TTF and OTF, can you add .otf to the list of allowed suffixes in findfont.go:50?

Thanks.

Unable to find TTC font

I use windows 10 operating system, some of which are in TTC format, but use findfont.List() function can only find the font format of TTF

Proposal: tag version 0.1.0 ?

Hi,

firstly, thank your for investing your time in a general purpose library !

As your lib seems to be quite stable over the last couple of month, would you mind tagging it with a zero version; something like v0.1.0? A zero version would not mean any commitment to API-stability from your side, as zero versions are supposed to be unstable.

However, it would help clients lock their dependencies in case you'll extend your lib to include fc-match or other feature-/API-changes.

Cheers,
--Norbert

go get fails on Windows and Mac

The platform specific files do not support "unix" as an option, so condition build tags need to be added to fontdirs-unix.go

I have included a pull request #3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.