Code Monkey home page Code Monkey logo

fbdigitalfont's Introduction

FBDigitalFont

Example

This library includes some kind of digital styled font drawer. They're not TTF files or something. They just draw fonts with CoreGraphics. So, you don't need to worry about redistribution license of font files when you release your application.

Example

Bitmap Font

BitmapFont

supporting

A-Z, 0-9, !:

LCD Font

LCDFont

supporting

0-9, dash

Square Font

SquareFont

supporting

A-Z, 0-9, dash

GLOWING EFFECT

I guess this kind of fonts have high affinity to glowing effects. So I support same effect as FBGlowLabel.

All you have to do is to set 4 properties.

  • glowColor
  • innnerGlowColor
  • glowSize
  • innerGlowSize

SETTING UP

If you use CocoaPods, add the following line to your Podfile

pod 'FBDigitalFont'

or directly git clone or download from this page.

IMPLEMENTATION

This includes some UIView classes which is customized to handle these fonts easily.

  • FBBitmapFontView
  • FBLCDFontView
  • FBSquareFontView

Or If you want, you can directly use drawer classes.

  • FBBitmapFont
  • FBLCDFont
  • FBSquareFont

Each of view classes require you to call resetSize method after modified properties to adjust view size according to modified parameters. Don't forget about this.

FBBitmapFontView

#import <FBDigitalFont/FBBitmapFontView.h>

- (void)setupBitmapFontView
{
    CGRect frame = CGRectMake(10, 60, 300, 50);
    FBBitmapFontView *v = [[FBBitmapFontView alloc] initWithFrame:frame];
    v.text = @"BITMAP";
    v.numberOfBottomPaddingDot = 1;
    v.numberOfTopPaddingDot    = 1;
    v.numberOfLeftPaddingDot   = 2;
    v.numberOfRightPaddingDot  = 2;
    v.glowSize = 20.0;
    v.innerGlowSize = 3.0;
    v.edgeLength = 5.0;
    [self.view addSubview:v];
    [v resetSize];
}
  • dotType
  • edgeLength
  • margin
  • numberOfLeftPaddingDot
  • numberOfTopPaddingDot
  • numberOfRightPaddingDot
  • numberOfBottomPaddingDot
  • numberOfPaddingDotWithinDigits numberOfPaddingDotsBetweenDigits
  • offColor
  • onColor
  • glowColor
  • innerGlowColo
  • glowSize
  • innerGlowSize
  • text

BitmapFontDescription

FBLCDFontView

#import <FBDigitalFont/FBLCDFontView.h>

- (void)setupLCDFontView
{
    CGRect frame = CGRectMake(40, 150, 300, 50);
    FBLCDFontView *v = [[FBLCDFontView alloc] initWithFrame:frame];
    v.text = @"20141231";
    v.lineWidth = 4.0;
    v.drawOffLine = YES;
    v.edgeLength = 20;
    v.margin = 10.0;
    v.backgroundColor = [UIColor blackColor];
    v.horizontalPadding = 20;
    v.verticalPadding = 14;
    v.glowSize = 10.0;
    v.glowColor = UIColorFromRGB(0x00ffff);
    v.innerGlowColor = UIColorFromRGB(0x00ffff);
    v.innerGlowSize = 3.0;
    [self.view addSubview:v];
    [v resetSize];
}
  • drawOffLine
  • edgeLength
  • margin
  • lineWidth
  • horizontalPadding
  • verticalPadding
  • glowSize
  • innerGlowSize
  • lineColor
  • offColor
  • glowColor
  • innerGlowColor
  • text

LCDFontDescription

FBSquareFontView

#import <FBDigitalFont/FBSquareFontView.h>

- (void)setupSquareFontView
{
    CGRect frame = CGRectMake(10, 240, 300, 50);
    FBSquareFontView *v = [[FBSquareFontView alloc] initWithFrame:frame];
    v.text = @"SQUARE";
    v.lineWidth = 3.0;
    v.lineCap = kCGLineCapRound;
    v.lineJoin = kCGLineJoinRound;
    v.margin = 12.0;
    v.backgroundColor = [UIColor blackColor];
    v.horizontalPadding = 30;
    v.verticalPadding = 14;
    v.glowSize = 10.0;
    v.glowColor = UIColorFromRGB(0x00ffff);
    v.innerGlowColor = UIColorFromRGB(0x00ffff);
    v.lineColor = UIColorFromRGB(0xffffff); // 0xffdd66
    v.innerGlowSize = 2.0;
    v.verticalEdgeLength = 12;
    v.horizontalEdgeLength = 14;
    [self.view addSubview:v];
    [v resetSize];
}

  • horizontalEdgeLength
  • verticalEdgeLength
  • margin
  • lineWidth
  • horizontalPadding
  • verticalPadding
  • glowSize
  • innerGlowSize
  • lineJoin
  • lineCap
  • lineColor
  • glowColor
  • innerGlowColor
  • text

SEE ALSO

If you don't need digital font but glowing effect, See FBGlowLabel

FBGlowLabelImage

FOR MORE DETAIL

This repository includes demo project, so you can dig into it for more details.

fbdigitalfont's People

Contributors

ijinmao avatar lyokato avatar philliptharris avatar vtourraine avatar xuan 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fbdigitalfont's Issues

Webfonts planed?

Hi,
are willing to render something out to create some web font files?
Best regards.

Support for Currency symbol?

I'd like to use a $ sign with this library. I'm going to go ahead and attempt to build my own, but it'd be a nice to have with this library.

Use in MarqueeLabel?

Hi, beautiful fonts. I wonder if there is a way to use them within another class -- one that performs an animation of the label? Thanks

Period in the LCD view

I have a need to display a period when using the LCD View. I have now added that capability. If there is any interest in this I can send the update to lyokato, fork the code, or just give the necessary changes here.

issue

Hi,

It is a cool library - great work!

However, we were using FBBitmapFont/View repeatedly [i.e. changing the text] and it is causing very large spike in memory - suddenly it grows to 50MB, 100MB and 200MB before it is killed by iOS.

  1. We have tested a few times and narrowed it down to this component. It happens very frequently if you change size of text and adjust the number of padding dots so it is centered.
  2. I've looked at Instruments and it is showing very huge single allocations [39MB, etc] with many CG calls.
  3. I've looked at the drawRect code and found a similar post here:
    http://stackoverflow.com/questions/19326551/sudden-memory-spike-with-cgcontextfillrect
    Most likely something like this is going on, but I am not a CoreGraphics expert.
  4. I also tested for potential UIGraphicsGetImageFromCurrentImageContext leak but it doesn't help:
    @autoreleasepool {
    per
    http://stackoverflow.com/questions/5121120/uigraphicsgetimagefromcurrentimagecontext-memory-leak-pdf-previews
    and ensure it runs on main thread
    per
    http://stackoverflow.com/questions/11582223/ios-ensure-execution-on-main-thread

Thanks in advance if you can look into it. Is a nice library.
Nicole

Implicit conversion loses integer precision: 'NSInteger' (aka "long") to FBFontSymbolType

In Class FBBitmapFontView.m Method numberOfHorizontalDot on line 72

FBFontSymbolType symbol = (int)[number integerValue];

Generates this warning when in XCODE 5.1.1 when compiling for 64 bit. Makes sense as the size of NSInteger is 8 and the enum is 4 in in this scenario. Looks like to me in this case, this can be safely ignored but if you want the warning to go away just change the line of code to this.

FBFontSymbolType symbol = (int)[number integerValue];

and cast the right hand side back to an int so it matches the enum.

extending this framework for drawing

Is there an easy way to create/extend the FBSquareFontView to draw graphics and apply the glow effects?

example:

CAShapeLayer * glowLayer = [CAShapeLayer layer];
//draw into the glowLayer
...
FBSquareView *v = [[FBSquareView alloc] initWithFrame:frame];
v.dotType = FBFontDotTypeSquare;
v.numberOfBottomPaddingDot = 1;
v.numberOfTopPaddingDot    = 1;
v.numberOfLeftPaddingDot   = 2;
v.numberOfRightPaddingDot  = 2;
v.glowSize = 20.0;
v.innerGlowSize = 3.0;
v.edgeLength = 5.0;
//apply glow to glowLayer
[v addSublayer: glowLayer];

Basically applying the same effect to your drawing layer or view.

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.