Skip to content

[Snippet Example] Font Awesome Lib

its-suun edited this page Sep 7, 2017 · 3 revisions

--@name Font Awesome Lib
--@author Damianu
--[[
    Names can be found here: http://fontawesome.io/cheatsheet/
    However due to lua syntax - has to be replaced with _
    Not all icons are present in table below, however using hexadecimal unicode of icon will also work inside lib's functions
]]
if SERVER then return end
FA = {
    glass="f000",
    music="f001",
    envelope_o="f003",
    heart="f004",
    star="f005",
    star_o="f006",
    user="f007",
    film="f008",
    th_large="f009",
    th="f00a",
    th_list="f00b",
    check="f00c",
    times="f00d",
    search_plus="f00e",
    search_minus="f010",
    power_off="f011",
    signal="f012",
    cog="f013",
    trash_o="f014",
    home="f015",
    file_o="f016",
    clock_o="f017",
    road="f018",
    download="f019",
    arrow_circle_o_down="f01a",
    arrow_circle_o_up="f01b",
    inbox="f01c",
    play_circle_o="f01d",
    repeat_="f01e",
    refresh="f021",
    list_alt="f022",
    lock="f023",
    flag="f024",
    headphones="f025",
    volume_off="f026",
    volume_down="f027",
    volume_up="f028",
    qrcode="f029",
    barcode="f02a",
    tag="f02b",
    tags="f02c",
    book="f02d",
    bookmark="f02e",
    print="f02f",
    camera="f030",
    font="f031",
    bold="f032",
    italic="f033",
    text_height="f034",
    text_width="f035",
    align_left="f036",
    align_center="f037",
    align_right="f038",
    align_justify="f039",
    list="f03a",
    outdent="f03b",
    indent="f03c",
    video_camera="f03d",
    picture_o="f03e",
    pencil="f040",
    map_marker="f041",
    adjust="f042",
    tint="f043",
    pencil_square_o="f044",
    share_square_o="f045",
    check_square_o="f046",
    arrows="f047",
    step_backward="f048",
    fast_backward="f049",
    backward="f04a",
    play="f04b",
    pause="f04c",
    stop="f04d",
    forward="f04e",
    fast_forward="f050",
    step_forward="f051",
    eject="f052",
    chevron_left="f053",
    chevron_right="f054",
    plus_circle="f055",
    minus_circle="f056",
    times_circle="f057",
    check_circle="f058",
    question_circle="f059",
    info_circle="f05a",
    crosshairs="f05b",
    times_circle_o="f05c",
    check_circle_o="f05d",
    ban="f05e",
    arrow_left="f060",
    arrow_right="f061",
    arrow_up="f062",
    arrow_down="f063",
    share="f064",
    expand="f065",
    compress="f066",
    plus="f067",
    minus="f068",
    asterisk="f069",
    exclamation_circle="f06a",
    gift="f06b",
    leaf="f06c",
    fire="f06d",
    eye="f06e",
    eye_slash="f070",
    exclamation_triangle="f071",
    plane="f072",
    calendar="f073",
    random="f074",
    comment="f075",
    magnet="f076",
    chevron_up="f077",
    chevron_down="f078",
    retweet="f079",
    shopping_cart="f07a",
    folder="f07b",
    folder_open="f07c",
    arrows_v="f07d",
    arrows_h="f07e",
    bar_chart_o="f080",
    twitter_square="f081",
    facebook_square="f082",
    camera_retro="f083",
    key="f084",
    cogs="f085",
    comments="f086",
    thumbs_o_up="f087",
    thumbs_o_down="f088",
    star_half="f089",
    heart_o="f08a",
    sign_out="f08b",
    linkedin_square="f08c",
    thumb_tack="f08d",
    external_link="f08e",
    sign_in="f090",
    trophy="f091",
    github_square="f092",
    upload="f093",
    lemon_o="f094",
    phone="f095",
    square_o="f096",
    bookmark_o="f097",
    phone_square="f098",
    twitter="f099",
    facebook="f09a",
    github="f09b",
    unlock="f09c",
    credit_card="f09d",
    rss="f09e",
    hdd_o="f0a0",
    bullhorn="f0a1",
    bell="f0f3",
    certificate="f0a3",
    hand_o_right="f0a4",
    hand_o_left="f0a5",
    hand_o_up="f0a6",
    hand_o_down="f0a7",
    arrow_circle_left="f0a8",
    arrow_circle_right="f0a9",
    arrow_circle_up="f0aa",
    arrow_circle_down="f0ab",
    globe="f0ac",
    wrench="f0ad",
    tasks="f0ae",
    filter="f0b0",
    briefcase="f0b1",
    arrows_alt="f0b2",
    users="f0c0",
    link="f0c1",
    cloud="f0c2",
    flask="f0c3",
    scissors="f0c4",
    files_o="f0c5",
    paperclip="f0c6",
    floppy_o="f0c7",
    square="f0c8",
    bars="f0c9",
    list_ul="f0ca",
    list_ol="f0cb",
    strikethrough="f0cc",
    underline="f0cd",
    table="f0ce",
    magic="f0d0",
    truck="f0d1",
    pinterest="f0d2",
    pinterest_square="f0d3",
    google_plus_square="f0d4",
    google_plus="f0d5",
    money="f0d6",
    caret_down="f0d7",
    caret_up="f0d8",
    caret_left="f0d9",
    caret_right="f0da",
    columns="f0db",
    sort="f0dc",
    sort_desc="f0dd",
    sort_asc="f0de",
    envelope="f0e0",
    linkedin="f0e1",
    undo="f0e2",
    gavel="f0e3",
    tachometer="f0e4",
    comment_o="f0e5",
    comments_o="f0e6",
    bolt="f0e7",
    sitemap="f0e8",
    umbrella="f0e9",
    clipboard="f0ea",
    lightbulb_o="f0eb",
    exchange="f0ec",
    cloud_download="f0ed",
    cloud_upload="f0ee",
    user_md="f0f0",
    stethoscope="f0f1",
    suitcase="f0f2",
    bell_o="f0a2",
    coffee="f0f4",
    cutlery="f0f5",
    file_text_o="f0f6",
    building_o="f0f7",
    hospital_o="f0f8",
    ambulance="f0f9",
    medkit="f0fa",
    fighter_jet="f0fb",
    beer="f0fc",
    h_square="f0fd",
    plus_square="f0fe",
    angle_double_left="f100",
    angle_double_right="f101",
    angle_double_up="f102",
    angle_double_down="f103",
    angle_left="f104",
    angle_right="f105",
    angle_up="f106",
    angle_down="f107",
    desktop="f108",
    laptop="f109",
    tablet="f10a",
    mobile="f10b",
    circle_o="f10c",
    quote_left="f10d",
    quote_right="f10e",
    spinner="f110",
    circle="f111",
    reply="f112",
    github_alt="f113",
    folder_o="f114",
    folder_open_o="f115",
    smile_o="f118",
    frown_o="f119",
    meh_o="f11a",
    gamepad="f11b",
    keyboard_o="f11c",
    flag_o="f11d",
    flag_checkered="f11e",
    terminal="f120",
    code="f121",
    reply_all="f122",
    star_half_o="f123",
    location_arrow="f124",
    crop="f125",
    code_fork="f126",
    chain_broken="f127",
    question="f128",
    info="f129",
    exclamation="f12a",
    superscript="f12b",
    subscript="f12c",
    eraser="f12d",
    puzzle_piece="f12e",
    microphone="f130",
    microphone_slash="f131",
    shield="f132",
    calendar_o="f133",
    fire_extinguisher="f134",
    rocket="f135",
    maxcdn="f136",
    chevron_circle_left="f137",
    chevron_circle_right="f138",
    chevron_circle_up="f139",
    chevron_circle_down="f13a",
    html5="f13b",
    css3="f13c",
    anchor="f13d",
    unlock_alt="f13e",
    bullseye="f140",
    ellipsis_h="f141",
    ellipsis_v="f142",
    rss_square="f143",
    play_circle="f144",
    ticket="f145",
    minus_square="f146",
    minus_square_o="f147",
    level_up="f148",
    level_down="f149",
    check_square="f14a",
    pencil_square="f14b",
    external_link_square="f14c",
    share_square="f14d",
    compass="f14e",
    caret_square_o_down="f150",
    caret_square_o_up="f151",
    caret_square_o_right="f152",
    eur="f153",
    gbp="f154",
    usd="f155",
    inr="f156",
    jpy="f157",
    rub="f158",
    krw="f159",
    btc="f15a",
    file="f15b",
    file_text="f15c",
    sort_alpha_asc="f15d",
    sort_alpha_desc="f15e",
    sort_amount_asc="f160",
    sort_amount_desc="f161",
    sort_numeric_asc="f162",
    sort_numeric_desc="f163",
    thumbs_up="f164",
    thumbs_down="f165",
    youtube_square="f166",
    youtube="f167",
    xing="f168",
    xing_square="f169",
    youtube_play="f16a",
    dropbox="f16b",
    stack_overflow="f16c",
    instagram="f16d",
    flickr="f16e",
    adn="f170",
    bitbucket="f171",
    bitbucket_square="f172",
    tumblr="f173",
    tumblr_square="f174",
    long_arrow_down="f175",
    long_arrow_up="f176",
    long_arrow_left="f177",
    long_arrow_right="f178",
    apple="f179",
    windows="f17a",
    android="f17b",
    linux="f17c",
    dribbble="f17d",
    skype="f17e",
    foursquare="f180",
    trello="f181",
    female="f182",
    male="f183",
    gittip="f184",
    sun_o="f185",
    moon_o="f186",
    archive="f187",
    bug="f188",
    vk="f189",
    weibo="f18a",
    renren="f18b",
    pagelines="f18c",
    stack_exchange="f18d",
    arrow_circle_o_right="f18e",
    arrow_circle_o_left="f190",
    caret_square_o_left="f191",
    dot_circle_o="f192",
    wheelchair="f193",
    vimeo_square="f194",
    try="f195",
    plus_square_o="f196",
    space_shuttle="f197",
    slack="f198",
    envelope_square="f199",
    wordpress="f19a",
    openid="f19b",
    university="f19c",
    graduation_cap="f19d",
    yahoo="f19e",
    google="f1a0",
    reddit="f1a1",
    reddit_square="f1a2",
    stumbleupon_circle="f1a3",
    stumbleupon="f1a4",
    delicious="f1a5",
    digg="f1a6",
    pied_piper="f1a7",
    pied_piper_alt="f1a8",
    drupal="f1a9",
    joomla="f1aa",
    language="f1ab",
    fax="f1ac",
    building="f1ad",
    child="f1ae",
    paw="f1b0",
    spoon="f1b1",
    cube="f1b2",
    cubes="f1b3",
    behance="f1b4",
    behance_square="f1b5",
    steam="f1b6",
    steam_square="f1b7",
    recycle="f1b8",
    car="f1b9",
    taxi="f1ba",
    tree="f1bb",
    spotify="f1bc",
    deviantart="f1bd",
    soundcloud="f1be",
    database="f1c0",
    file_pdf_o="f1c1",
    file_word_o="f1c2",
    file_excel_o="f1c3",
    file_powerpoint_o="f1c4",
    file_image_o="f1c5",
    file_archive_o="f1c6",
    file_audio_o="f1c7",
    file_video_o="f1c8",
    file_code_o="f1c9",
    vine="f1ca",
    codepen="f1cb",
    jsfiddle="f1cc",
    life_ring="f1cd",
    circle_o_notch="f1ce",
    rebel="f1d0",
    empire="f1d1",
    git_square="f1d2",
    git="f1d3",
    hacker_news="f1d4",
    tencent_weibo="f1d5",
    qq="f1d6",
    weixin="f1d7",
    paper_plane="f1d8",
    paper_plane_o="f1d9",
    history="f1da",
    circle_thin="f1db",
    header="f1dc",
    paragraph="f1dd",
    sliders="f1de",
    share_alt="f1e0",
    share_alt_square="f1e1",
    bomb="f1e2",
}
local function unichar(c1)
    if type(c1) != "number" then
        c1 = tonumber(c1,16)
    end

    return string.utf8char(c1)
end

local awesomeFonts = {}

local function getFont(size)
    if not awesomeFonts[size] then
        awesomeFonts[size] = render.createFont("FontAwesome", size, 400, true, false, false, false, false, true)
    end
    return awesomeFonts[size]
end

function render.drawIcon(x, y, icon, size)
    icon = unichar(icon)
    
    render.setFont(getFont(size))
    render.drawText(x, y, icon, 0)
end
Clone this wiki locally