GithubHelp home page GithubHelp logo

go-fbink's Introduction

go-fbink

go-fbink is a Go wrapper for the fbink tool found at https://github.com/NiLuJe/FBInk

It is currently tied to FBInk 1.5.0

Installation and usage

go-fbink can be installed by doing the following:

go get github.com/shermp/go-fbink
// download the FBInk submodule
cd $GOPATH/src/github.com/shermp/go-fbink
git submodule update --init --recursive

A precompiled static library is included for convenience if you are using a Kobo device. If you wish or need to compile your own library, you will need to make the "pic" target when compiling fbink from the FBInk directory

The static library should reside in fbinklib/libfbink.a

From your Go project, import go-fbink as follows:

import gofbink "github.com/shermp/go-fbink"

Note, you will need to enable cgo support when building your project, by setting the CGO_ENABLED=1 environment variable when building, along with setting the CC and CXX environment variables to your ARM toolchain's GCC and G++ paths respectively.

A simple example of usage is:

fbinkOpts := gofbink.FBInkConfig{
		Row:         4,
		Fontmult:    2,
		Fontname:    gofbink.UNSCIIfantasy,
		IsCentered:  true,
		Valign:      gofbink.Center
		Halign:      gofbink.Center
	}
	gofbink.Init(gofbink.FBFDauto, fbinkOpts)
	gofbink.Print(gofbink.FBFDauto, "This is a test", fbinkOpts)

	fbinkOpts.Row = 8
	gofbink.Init(gofbink.FBFDauto, fbinkOpts)
	gofbink.Print(gofbink.FBFDauto, "This is another test", fbinkOpts)

	gofbink.PrintImage(gofbink.FBFDauto, "koreader.png", 10, 20, fbinkOpts)

You can refer to the original documentation found in the fbink.h file, which can be found at fbinkinclude/fbink.h. The usage is almost identical.

The primary usage difference is that where appropriate, go-fbink returns an error, or nil, rather than an integer to indicate success or failure. Note that the error string contains the C error code name (eg: "EXIT_FAILURE").

The only function that is unavailable in go-fbink is fbink_printf(). This is because cgo does not support variadic parameters.

go-fbink's People

Contributors

shermp avatar

Stargazers

 avatar

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.