You are here

function _ascii_art_captcha_available_fonts in CAPTCHA Pack 8

Same name and namespace in other branches
  1. 5 ascii_art_captcha/ascii_art_captcha.module \_ascii_art_captcha_available_fonts()
  2. 6 ascii_art_captcha/ascii_art_captcha.admin.inc \_ascii_art_captcha_available_fonts()
  3. 7 ascii_art_captcha/ascii_art_captcha.admin.inc \_ascii_art_captcha_available_fonts()

Function to get a list of available fonts.

@TODO: Rebuild loading fonts with plugins.

Return value

array returns list of available fonts.

1 call to _ascii_art_captcha_available_fonts()
AsciiArtCaptchaSettingsForm::buildForm in ascii_art_captcha/src/Form/AsciiArtCaptchaSettingsForm.php
Form constructor.

File

ascii_art_captcha/ascii_art_captcha.module, line 18
Contains general functionality of the module.

Code

function _ascii_art_captcha_available_fonts() {
  $available_fonts = [];
  $fontsdirectory = drupal_get_path('module', 'ascii_art_captcha') . '/fonts';
  $pattern = '/ascii_art_captcha_font_([a-zA-Z0-9]+)\\.[iI][nN][cC]$/';
  $directory_files = file_scan_directory($fontsdirectory, $pattern);
  foreach ($directory_files as $font) {
    $regs = [];
    preg_match($pattern, $font->filename, $regs);
    $available_fonts[$regs[1]] = $regs[1];
  }
  asort($available_fonts);
  return $available_fonts;
}